//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    internal class TableCellBorderStyle : IOfficeXmlSerializable
    {
        internal const string xmlName = "tcBdr";
        private ThemeableLineStyle _bottom;
        private OfficeArtExtensionList _extLst;
        private ThemeableLineStyle _insideH;
        private ThemeableLineStyle _insideV;
        private ThemeableLineStyle _left;
        private ThemeableLineStyle _right;
        private ThemeableLineStyle _tl2br;
        private ThemeableLineStyle _top;
        private ThemeableLineStyle _tr2bl;

        #region IOfficeXmlSerializable Members

        public void ReadXml(ReadContext context)
        {
            using (var c = context.Read(xmlName))
            {
                _left = c.ReadOptionalElementAs<ThemeableLineStyle>("left");
                _right = c.ReadOptionalElementAs<ThemeableLineStyle>("right");
                _top = c.ReadOptionalElementAs<ThemeableLineStyle>("top");
                _bottom = c.ReadOptionalElementAs<ThemeableLineStyle>("bottom");
                _insideH = c.ReadOptionalElementAs<ThemeableLineStyle>("insideH");
                _insideV = c.ReadOptionalElementAs<ThemeableLineStyle>("insideV");
                _tl2br = c.ReadOptionalElementAs<ThemeableLineStyle>("tl2br");
                _tr2bl = c.ReadOptionalElementAs<ThemeableLineStyle>("tr2bl");
                _extLst = c.ReadOptionalElement<OfficeArtExtensionList>("extLst");
            }
        }

        public void WriteXml(WriteContext context)
        {
            using (var c = context.Write(xmlName))
            {
                c.WriteOptionalElementAs(_left, "left");
                c.WriteOptionalElementAs(_right, "right");
                c.WriteOptionalElementAs(_top, "top");
                c.WriteOptionalElementAs(_bottom, "bottom");
                c.WriteOptionalElementAs(_insideH, "insideH");
                c.WriteOptionalElementAs(_insideV, "insideV");
                c.WriteOptionalElementAs(_tl2br, "tl2br");
                c.WriteOptionalElementAs(_tr2bl, "tr2bl");
                c.WriteOptionalElement(_extLst);
            }
        }

        #endregion
    }
}